<#assign module="order"/>

<@override name="header">
</@override>
<@override name="body">
<div class="row">
  <div class="col-xs-12 col-md-5">
  	<@shiro.hasPermission name='orderrealtime'>
  	<div class="btn-group">
  		<a href="${ctx}/order/realtime" class="btn btn-danger">
		  <span class="glyphicon glyphicon-time"></span> 时效
		</a>
  	</div>
  	</@shiro.hasPermission>
  	<@shiro.hasPermission name='order'>
  	<div class="btn-group">
	  <a class="btn btn-default active" href="${ctx}/order/list">执行中</a>
	  <#assign refusedAmount=Func.refusedOrderAmount()>
	  <a class="btn btn-default" href="${ctx}/order/refuselist">拒单<#if refusedAmount?? && (refusedAmount>0)>-<span id="refuse_label" class="label label-danger">${refusedAmount}</span></#if></a>
	  <a class="btn btn-default" href="${ctx}/order/cancellist">已销单</a>
	  <a class="btn btn-default" href="${ctx}/order/warmlist">异常订单</a>
	  <a class="btn btn-default" href="${ctx}/order/finishlist">已结算</a>
	  <a class="btn btn-default" href="${ctx}/order/baodanlist">已报单</a>
	</div>
	</@shiro.hasPermission>
  </div>
  
  <div class="col-xs-12 col-md-4">
  	<form class="form-inline" role="form">
	  	<div class="form-group col-xs-9">
	  		<input type="text" class="form-control" style="width:100%;" name="param" value="${param?if_exists}"  placeholder="输入订单号、客户电话、服务人员姓名、服务人员电话、目的地">
	  	</div>
	  	<button type="submit" class="btn btn-primary"><i class="icon-search"></i>&nbsp;搜索</button>
  	</form>
  </div>
  
  <div class="col-xs-12 col-md-3">
  	<button class="pull-right btn btn-primary" onclick="window.open('${ctx}/order/add', '_blank', 'height=770,width=1220,scrollbars=yes,resizable=yes,alwaysRaised=yes,toolbar=no');"><i class="icon-plus"></i>&nbsp;添加新订单</button>
  	<button class="pull-right btn btn-primary btn-primary-a" onclick="window.location.reload(true);"><i class="icon-refresh"></i>&nbsp;刷新</button>
  </div>
  
</div>

<div class="row margin-top">
	<div class="col-xs-12">
	<div class="panel panel-primary">
		<div class="table-responsive">
		<table class="table table-hover table-striped">
			<thead>
			<tr style="font-size:14px;">
				<th style="padding-left:20px;width:80px;">状态</th>
				<th>单号</th>
				<@shiro.isMainCompany>
				<th>所属公司</th>
				</@shiro.isMainCompany>
				<th class="hidden-xs">类型</th>
				<th class="hidden-xs">来源</th>
				<th>预约时间</th>
				<th>预约地</th>
				<th>客户姓名</th>
				<th>客户电话</th>
				<th>接单服务人员</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
				<#if (page.content)?? >
			  	<#list page.content as data>
				<tr>
					<td style="padding-left:15px;">
						<#if data.status==0>
							<span class="label label-info">未派单</span>
						<#elseif data.status==1>
							<span class="label label-warning">已派单</span>
						<#elseif data.status==2>
							<span class="label label-danger">服务中</span>
						<#elseif data.status==3>
							<span class="label label-success">已结算</span>
						<#elseif data.status==4>
							<span class="label label-primary">服务人员拒单</span>
						<#elseif data.status==5>
							<span class="label label-default">已销单</span>
						<#elseif data.status==6>
							<span class="label label-success">已报单</span>
						<#elseif data.status==7>
							<span class="label label-warning">预派单</span>
						</#if>
					</td>
					<td>
						<a target="_blank" href="${ctx}/order/detail/${data.id}" class="btn-link">***${data.orderNumber?substring(8)}</a>
						<@zhuan>
							<#if data.orderCarType=="daijia">
								<span class="label label-danger status-td">代</span>
							<#elseif data.orderCarType=="zhuanche">
								<span class="label label-warning status-td">专</span>
							</#if>
						</@zhuan>
						<#if data.insurance??>
							<span class="label label-success status-td baoxian" title="${data.insurance.pinganNo?if_exists}#${data.insurance.insuranceNo?if_exists}">保</span>
						</#if>
					</td>
					<@shiro.isMainCompany>
					<td>${data.company.abbreviation?if_exists}</td>
					</@shiro.isMainCompany>
					<td class="hidden-xs">${data.orderType?if_exists}</td>
					<td class="hidden-xs">${data.fromSource?if_exists}</td>
					<td>${data.serverTime?string('MM/dd HH:mm')}</td>
					<td style="max-width:250px;">
						${data.fromPlace?if_exists}
					</td>
					<td>${data.clientName?if_exists}</td>
					<td>${data.clientPhone?if_exists}</td>
					<td>
						${data.driverRealName!'无'}
					</td>
					<td>
						
						<#if data.status==0>
							<@shiro.hasPermission name='dispatch'>
							<a class="btn-link" href="${ctx}/order/paidan/${data.id}">派单</a>
							</@shiro.hasPermission>
						</#if>
						<#if data.status==0 || data.status==1 || data.status==4 || data.status==7>
							<a href="javascript:;" data-value="${data.id}" class="btn-link cancelthis">销单</a>
						</#if>
						<#if data.status==1 || data.status==7>
							<a href="javascript:;" data-value="${data.id}" class="btn-link revokethis">收回</a>
						</#if>
						<#if data.status==2>
							<@shiro.hasPermission name='powercancel'>
							<a href="javascript:;" data-value="${data.id}" class="btn-link powercancelthis">销单</a>
							</@shiro.hasPermission>
							<@shiro.hasPermission name='powerrevoke'>
								<#if !data.daijiaTime2??>
									<a href="javascript:;" data-value="${data.id}" class="btn-link powerrevokethis">收回</a>
								</#if>
							</@shiro.hasPermission>
						</#if>
						<a href="javascript:;" data-value="${data.id}" data-value-memo="${data.memo?if_exists}" class="btn-link memothis">备注</a>
						<a href="javascript:;" class="btn-link" onclick="window.open('${ctx}/order/addmore/${data.id}', '_blank', 'height=770,width=1220,scrollbars=yes,resizable=yes,alwaysRaised=yes,toolbar=no');">追加</a>
						<@shiro.hasPermission name='orderComplete'>
							<#if data.status==1 || data.status==2 || data.status==7>
								<a href="javascript:;" class="btn-link" onclick="window.open('${ctx}/order/complete/${data.id}', '_blank', 'height=500,width=900,scrollbars=yes,resizable=yes,alwaysRaised=yes,toolbar=no');">完工</a>
							</#if>
						</@shiro.hasPermission>
						<!--
						<#if data.recording?? && (data.recording?length>0)>
							<button type="button" class="btn btn-default btn-xs playrecord"  data-url="${ctx}/upload/tell/${data.created?string('yyyy-MM')}/${data.created?string('dd')}/${data.recording}.mp3">
							  <span class="glyphicon glyphicon-play"></span> 播放
							</button>
						</#if>
						-->
						
					</td>
				</tr>
				</#list>
				</#if>
			</tbody>
		</table>
		<#if page.totalElements??>
		<ul class="pagination pull-right pagination-sm">
			<li><a>共 ${page.totalElements} 条数据</a></li>
			<@pg.pager items=page.totalElements?number maxPageItems=20 export="currentPageNumber=pageNumber" url="${ctx}/order/list">
				<@pg.param name="param" value="${param?if_exists}"/>
				<@pg.index>
					<@pg.first>
						<li><a href="${pageUrl}">&laquo;</a></li>
					</@pg.first>
					<@pg.prev>
						<li><a href="${pageUrl}">&lsaquo;</a></li>
					</@pg.prev>
					<@pg.pages>
						<#if  currentPageNumber == pageNumber >
							<li class="active"><a href="#">${pageNumber}</a></li>
						<#else>
							<li><a href="${pageUrl}">${pageNumber}</a></li>
						</#if>
					</@pg.pages>
					<@pg.next>
						<li><a href="${pageUrl}">&rsaquo;</a></li>
					</@pg.next>
					<@pg.last>
						<li><a href="${pageUrl}">&raquo;</a></li>
					</@pg.last>
				</@pg.index>
			</@pg.pager>
		</ul>
		</#if>
	</div>
	</div>
	</div>
</div>

<form id="cancel_form" class="form-horizontal" action="${ctx}/order/cancelpost" method="post">
<div class="modal fade" id="dialog_cancel">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">输入销单原因</h4>
      </div>
      <div class="modal-body">
      	<input type="hidden" name="id" id="dialog_cancel_id">
      	
      	<div class="form-group">
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="cancel_reason" value="与客户协商一致取消订单"> 与客户协商一致取消订单
					</label>
				</p>
            </div>
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="cancel_reason" value="客户呼叫多人，只用先到服务人员"> 客户呼叫多人，只用先到服务人员
					</label>
				</p>
            </div>
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="cancel_reason" value="客户拒接电话"> 客户拒接电话
					</label>
				</p>
            </div>
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="cancel_reason" value="客户单方面取消"> 客户单方面取消
					</label>
				</p>
            </div>
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="cancel_reason" value="other"> 其他 
					</label>
				</p>
            </div>
        </div>
      	
      	<div class="form-group">
            <div class="col-sm-12">
                <textarea class="form-control" cols="20" id="dialog_cancel_content" name="content" rows="2" required></textarea>
            </div>
        </div>
      </div>
      <div class="modal-footer">
    	<button type="button" class="btn btn-primary" id="ok_modal_cancel">提交</button>
    	<button type="button" class="btn btn-default" id="close_modal_cancel">关闭</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>
</form>

<form id="powercancel_form" class="form-horizontal" action="${ctx}/order/powercancelpost" method="post">
<div class="modal fade" id="dialog_powercancel">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">输入销单原因</h4>
      </div>
      <div class="modal-body">
      	<input type="hidden" name="id" id="dialog_powercancel_id">
      	
      	<div class="form-group">
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="powercancel_reason" value="与客户协商一致取消订单"> 与客户协商一致取消订单
					</label>
				</p>
            </div>
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="powercancel_reason" value="客户呼叫多人，只用先到服务人员"> 客户呼叫多人，只用先到服务人员
					</label>
				</p>
            </div>
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="powercancel_reason" value="客户拒接电话"> 客户拒接电话
					</label>
				</p>
            </div>
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="powercancel_reason" value="客户单方面取消"> 客户单方面取消
					</label>
				</p>
            </div>
            <div class="col-sm-12">
                <p class="form-control-static">
					<label style="padding-right:20px;">
						<input type="radio" name="powercancel_reason" value="other"> 其他
					</label>
				</p>
            </div>
        </div>
        
      	<div class="form-group">
            <div class="col-sm-12">
                <textarea class="form-control" cols="20" id="dialog_powercancel_content" name="content" rows="2"></textarea>
            </div>
        </div>
      </div>
      <div class="modal-footer">
    	<button type="button" class="btn btn-primary" id="ok_modal_powercancel">提交</button>
    	<button type="button" class="btn btn-default" id="close_modal_powercancel">关闭</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>
</form>

<form class="form-horizontal" action="${ctx}/order/revoke" method="post">
<div class="modal fade" id="dialog_revoke">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">输入收回原因</h4>
      </div>
      <div class="modal-body">
      	<input type="hidden" name="id" id="dialog_revoke_id">
      	<div class="form-group">
            <div class="col-sm-12">
                <textarea class="form-control" cols="20" id="dialog_revoke_content" name="content" rows="2" required></textarea>
            </div>
        </div>
      </div>
      <div class="modal-footer">
    	<button type="submit" class="btn btn-primary" id="ok_modal_revoke">提交</button>
    	<button type="button" class="btn btn-default" id="close_modal_revoke">关闭</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>
</form>

<form class="form-horizontal" action="${ctx}/order/powerrevoke" method="post">
<div class="modal fade" id="dialog_powerrevoke">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">输入收回原因</h4>
      </div>
      <div class="modal-body">
      	<input type="hidden" name="id" id="dialog_powerrevoke_id">
      	<div class="form-group">
            <div class="col-sm-12">
                <textarea class="form-control" cols="20" id="dialog_powerrevoke_content" name="content" rows="2" required></textarea>
            </div>
        </div>
      </div>
      <div class="modal-footer">
    	<button type="submit" class="btn btn-primary" id="ok_modal_powerrevoke">提交</button>
    	<button type="button" class="btn btn-default" id="close_modal_powerrevoke">关闭</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>
</form>

<form id="memo_form" class="form-horizontal" action="${ctx}/order/memopost" method="post">
<div class="modal fade" id="dialog_memo">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">添加订单备注</h4>
      </div>
      <div class="modal-body">
      	<input type="hidden" name="id" id="dialog_memo_id">
      	<div class="form-group">
            <label class="col-sm-3 control-label">输入新备注：</label>
            <div class="col-sm-9">
                <textarea class="form-control" cols="20" id="dialog_memo_newcontent" name="memo" rows="2" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">已有备注：</label>
            <div class="col-sm-9">
                <p class="form-control-static" id="dialog_memo_oldcontent"></p>
            </div>
        </div>
      </div>
      <div class="modal-footer">
    	<button type="button" class="btn btn-primary" id="ok_modal_memo">提交</button>
    	<button type="button" class="btn btn-default" id="close_modal_memo">关闭</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>
</form>

</@override>


<@override name="footer">
	<script type="text/javascript">
		window.daijia = {
			ctx:'${ctx}',
			userId:'<@shiro.principal property='id'/>'
		};
	
		<#if message??>
			$.scojs_message("${message}", $.scojs_message.TYPE_ERROR);
		</#if>
		
		<#if info??>
			$.scojs_message("${info}", $.scojs_message.TYPE_OK);
		</#if>
	</script>
	<script src="${ctx}/assets/js/orderlist.js"></script>
	<script src="${ctx}/assets/js/pushmessage.js"></script>
</@override>
<@extends name="../layout.ftl"/>